package xyz.csmcool.imuser.service.impl;

import lombok.RequiredArgsConstructor;
import xyz.csmcool.imuser.entity.Contact;
import xyz.csmcool.imuser.entity.vo.ContactVo;
import xyz.csmcool.imuser.mapper.ContactMapper;
import xyz.csmcool.imuser.service.IContactService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import xyz.csmcool.imutil.ExceptionHandler.CommonException;
import xyz.csmcool.imutil.webVo.ResultCode;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author csmcool
 * @since 2022-08-03
 */
@Service
@RequiredArgsConstructor
public class ContactServiceImpl extends ServiceImpl<ContactMapper, Contact> implements IContactService {

    final ContactMapper contactMapper;

    @Override
    public void updateContact(ContactVo contactVo) {
        Boolean aBoolean = getBaseMapper().updateContactInfo(contactVo.getContactName(), contactVo.getContactInfo());
        if (!aBoolean) {
            throw new CommonException(ResultCode.CUSTOM_FAIL.setCode(999).setMessage("更新联系方式出错了，稍后重试"));
        }
    }
}
